package com.liyuhan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 李宇寒王二小
 * Description:测试
 * 2019/2/18 0018 下午 8:03.
 */
@Controller
@RequestMapping("/hello")
public class HelloMySpringBoot {

    @RequestMapping
    @ResponseBody
    public String sayHello() {
        return("Hello SpringBoot");
    }

    @RequestMapping("/sayYourName")
    public Map<String, String> getInfo(@RequestParam String name) {
        Map<String, String> map = new HashMap<>();
        map.put("name", name);
        return map;
    }

    @RequestMapping("/showList")
    public List<Map<String, String>> getList() {

        List<Map<String, String>> list = new ArrayList<>();

        Map<String, String> map = null;

        for (int i = 1; i <= 5; i++) {
            map = new HashMap<>();
            map.put("name", "Liyuhan-" + i);
            list.add(map);
        }
        return list;
    }
}
